home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.4 Applications 1997 August / SGI IRIX 6.4 Applications 1997 August.iso / dist / mmailp.idb / usr / lib / Zmail / bin / showpartial.z / showpartial
Encoding:
Text File  |  1997-01-22  |  2.4 KB  |  93 lines

  1. #!/bin/csh -fb
  2. # (The "-fb" might need to be changed to "-f" on some systems)
  3. #
  4.  
  5. if (! $?METAMAIL_TMPDIR) then
  6.     set METAMAIL_TMPDIR=/tmp
  7. endif
  8.  
  9. set TREEROOT=${METAMAIL_TMPDIR}/m-prt-`whoami`
  10. if ($#argv < 3 || $#argv > 4) then
  11.     echo "Usage:  showpartial file id partnum totalnum"
  12.     exit -1
  13. endif
  14. set file=$1
  15. # This next line is because message-id can contain weird chars
  16. set id=`echo $2 | tr -d  \!\$\&\*\(\)\|\'\"\;\/\<\>\\` 
  17. @ partnum = $3
  18. if ($#argv == 3 || $4 == "") then
  19.     set totalnum=-1
  20. else
  21.     @ totalnum = $4
  22. endif
  23.  
  24. if (! -d  $TREEROOT)  then
  25.     mkdir $TREEROOT
  26.     if ($status) then 
  27.         echo mkdir $TREEROOT failed
  28.         exit -1
  29.     endif
  30. endif
  31. if (! -d ${TREEROOT}/$id) then 
  32.     mkdir ${TREEROOT}/$id
  33.     if ($status) then 
  34.         echo mkdir ${TREEROOT}/$id failed
  35.         exit -1
  36.     endif
  37. endif
  38. cp $file ${TREEROOT}/$id/$partnum
  39. if ($status) then 
  40.     echo cp $file ${TREEROOT}/$id/$partnum failed
  41.     exit -1
  42. endif
  43. if ($totalnum == -1) then
  44.     if (-e ${TREEROOT}/$id/CT) then
  45.     set totalnum=`cat ${TREEROOT}/$id/CT`
  46.     else
  47.         set totalnum=-1  #GROSS HACK
  48.     endif
  49. else
  50.     echo $totalnum >! ${TREEROOT}/$id/CT
  51. endif
  52. # Slightly bogus here -- the shell messes up the newlines in the headers
  53. # If you put $MM_HEADERS in quotes, it doesn't help.
  54. # if ($partnum == 1) then
  55. #     echo $MM_HEADERS > ${TREEROOT}/$id/HDRS
  56. # endif
  57. set found=0
  58. set ix=1
  59. set list=""
  60. set limit=$totalnum
  61. if ($limit == -1) set limit=25
  62. while ($ix <= $limit)
  63.     if (-e ${TREEROOT}/$id/$ix) then
  64.     set list="$list $ix"
  65.     @ found ++
  66.     endif
  67.     @ ix ++
  68. end
  69. if ($found == $totalnum) then
  70.     cd ${TREEROOT}/$id
  71.     cat $list > ${TREEROOT}/$id/FULL
  72. #    cat ${TREEROOT}/$id/HDRS $list > ${TREEROOT}/$id/FULL
  73.     rm $list
  74.     echo All parts of this ${totalnum}-part message have now been read.
  75.     metamail -d  ${TREEROOT}/$id/FULL
  76.     echo WARNING:  To save space, the full file is now being deleted.  
  77.     echo You will have to read all $totalnum parts again to see the full message again.
  78.     rm ${TREEROOT}/$id/FULL
  79.     rm ${TREEROOT}/$id/CT
  80. #    rm ${TREEROOT}/$id/HDRS
  81.     cd
  82.     rmdir ${TREEROOT}/$id
  83.     rmdir ${TREEROOT} >& /dev/null
  84. else
  85.     if (${totalnum} == -1) then
  86.         echo So far you have only read $found of the several parts of this message.
  87.     else
  88.         echo So far you have only read $found of the $totalnum parts of this message.
  89.     endif
  90.     echo When you have read them all, then you will see the message in full.
  91. endif
  92.     
  93.